<!DOCTYPE html>
<html class="x-admin-sm">

<head>
	<meta charset="UTF-8">
	<title>电子学会比赛管理系统</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
	<link rel="stylesheet" href="./css/font.css">
	<link rel="stylesheet" href="./css/common.css">
	<link rel="stylesheet" href="./css/xadmin.css">
	<script type="text/javascript" src="./js/abkj/match/api/mathworklistview.js"></script>
	<script type="text/javascript" src="./js/abkj/ext/programexamrecord.js"></script>
	<script type="text/javascript" src="./js/abkj/ext/programlib.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/zone.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/topic.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/grade.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/schedule.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/matchzoneview.js"></script>

	<script type="text/javascript" src="./js/abkj/match/api/scheduleitem.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/scheduletype.js"></script>
		<script type="text/javascript" src="./js/abkj/auth/api/userinfoview.js"></script>
	<script type="text/javascript" src="./js/abkj/slAjax.js"></script>
	<script type="text/javascript" src="./js/abkj/fun_tool.js"></script>
	<script src="./lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="./js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
								<a><cite>比赛管理</cite></a>
                <a><cite>编程作品</cite></a>
            </span>
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
		<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
	</a>
</div>
<div class="layui-fluid" id="content" v-cloak>
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md12">
			<div class="layui-card">
				<div class="layui-card-body ">
					<div class="layui-form layui-col-space5 flex" style="display: flex;">
						<!--<div class="layui-input-inline layui-show-xs-block">-->
						<!--<input class="layui-input" placeholder="开始日" name="start" id="start"></div>-->
						<!--<div class="layui-input-inline layui-show-xs-block">-->
						<!--<input class="layui-input" placeholder="截止日" name="end" id="end"></div>-->
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">赛项</div>
							<select id="saixiang">
								<option value="">请选择</option>

										<option v-for="item in mlist" :value="item.theme">{{item.theme}}</option>

							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">赛区</div>
							<select id="saiqu">
								<option value="">请选择</option>
								 <option v-for="item in zoneList" :value="item.zoneName">{{item.zoneName}}</option>

							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">组别</div>
							<select id="zubie">
								<option value="">请选择</option>
								<option v-for="item in gradeList" :value="item.gradeName">{{item.gradeName}}</option>

							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5" style="width: 40px;display:none">账号</div>
							<input type="text" name="number" id="zhanghao" placeholder="账号" autocomplete="off" class="layui-input" style="display:none"></div>
						<div class="layui-input-inline layui-show-xs-block">
							<button class="layui-btn" lay-submit="" lay-filter="sreach" onclick="search()">
								<i class="layui-icon">&#xe615;</i></button>
						</div>
					</div>
				</div>
				<div class="layui-card-header">
					<!--<button class="layui-btn layui-btn-danger" onclick="delAll()">-->
						<!--<i class="layui-icon"></i>批量删除-->
					<!--</button>-->
					<!--<button class="layui-btn" onclick="xadmin.open('添加用户','./order-add.html',800,600)">-->
						<!--<i class="layui-icon"></i>添加-->
					<!--</button>-->
				</div>
				<div class="layui-card-body" >
					<table class="layui-table layui-form" id="test" lay-filter="test">
						<span style="float: left;">共计{{total}}条数据</span>
						<div class="layui-btn-container">
								<!-- <button id="referee" class="layui-btn layui-btn-sm layui-btn-disabled" onclick="selectcaipan()" style="float: right;">选择裁判</button>	</div> -->
						<!--<div class="layui-btn-container">-->
							<!--<button class="layui-btn layui-btn-sm"  style="float: right;">批量下载</button>-->
						<!--</div>-->
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script src="./js/vue.js"></script>
<script>
function selectcaipan(){
	var table = layui.table
	var data=table.checkStatus('test').data
	// alert(JSON.stringify(data))
	var idstring=[]
	for (i=0;i<data.length;i++){
	 idstring.push(data[i].id)
	}
	localStorage.zuopinid=idstring.toString()
	var param = {
		eq:{
			roleId:4
		}
	}

	UserinfoViewqueryList(param,function(data){
						localStorage.selectcaipanlist=JSON.stringify(data)
						xadmin.open('选择裁判','./selectReferee2.html',700,500)
	})

}
var form
layui.use(['form', 'table'], function () {

	 form = layui.form
})
	var app=new Vue({
		el: '#content',
		data: {
			list:[],
			aaa: 123,
			mlist:[],
			zoneList:[],
			gradeList:[],
			total:0,
			scheduletypeList:[],
			status:['审核','待审核' ,'通过', '不通过'],
			participate:['审核','参赛' ,'弃权' ],
			cols: [ // 表头
				{type: 'checkbox', fixed: 'left'},
				{field: 'index', title: '序号', width: 80},
				{field: 'userId', title: '账户', width: 80},
				{field: 'unitName', title: '编辑器名称', width: 80},
				{field: 'signupId', title: '团队ID', width: 80},
				{field: 'matchName', title: '赛项'},
				{field: 'zoneName', title: '赛区'},
				{field: 'scheduleName', title: '赛程'},
				{field: 'gradeName', title: '组别'},

				{field: 'url', title: '预览',templet:"#operating2"},
				// {field: 'teacher', title: '图片',templet: function(res){
				// 		return '<a target="_blank" href="./PreviewImg.html" class="layui-table-link">'+ '预览 ' +'</a>'
				// 	}},
				// {field: 'teacher', title: '文档',templet: function(res){
				// 		return '<a target="_blank" href="./PreviewExcel.html" class="layui-table-link">'+ '预览 ' +'</a>'
				// 	}},
				{field: 'startTime', title: '答题开始时间'},
				{field: 'endTime', title: '答题结束时间'},
				// {field: 'operating', title: '操作', width: 135, templet: '#operating'},
			]
		},
		methods:{
			opentab:function(name,url){
				//单击事件
				console.log(name)
				console.log(url)
				xadmin.add_tab(name,url)
			},
			getMatchName:function(varMatchId,index){
			 // alert(varMatchId)
			 console.log(JSON.stringify(this.mlist))
				for(var i=0; i<this.mlist.length;++i){

					if(this.mlist[i].id == varMatchId){

						// alert(this.matchList[i].theme)
						return this.mlist[i].theme;
					}
				}
				return null;
			},
			getZoneName:function(varZoneId){
				for(var i=0; i<this.zoneList.length;++i){
					if(this.zoneList[i].id == varZoneId){
						// alert(this.zoneList[i].zoneName)
						return this.zoneList[i].zoneName;
					}
				}
				return null;
			},
			getGradeName:function(varGradeId){
				for(var i=0; i<this.gradeList.length;++i){
					if(this.gradeList[i].id == varGradeId){
						return this.gradeList[i].gradeName;
					}
				}
				return null;
			},
			getsaicheng:function(saichengid){
				// alert(saichengid)
				for(var i=0; i<this.scheduletypeList.length;++i){
					if(this.scheduletypeList[i].id == saichengid){
						return this.scheduletypeList[i].scheduleName;
					}
				}
				return null;
			},
			getData(){
				MatchZoneViewqueryList({}, function (data) {
					app.mlist=data
				 var records=data
				 var list=[]
				 var list1=[]

				 for (i=0;i<records.length;i++){
						 var string1=list1.toString()
						 if (string1.indexOf(records[i].id)==-1){
							 list1.push(records[i].id)
							 list.push(records[i])
						 }
				 }
				 app.mlist=list
				 ZonequeryList({}, function (data) {
					//  alert(JSON.stringify(data))
					app.zoneList = data
					GradequeryList({}, function (data) {
						//  alert(JSON.stringify(data))
						app.gradeList= data
						SchedulequeryList({}, function (data) {

							app.scheduletypeList = data
							// alert(JSON.stringify(app.scheduletypeList))
							var queryData = {
								    page:{
								        current:1, //当前页数
								        size:10   //每页长度
								    },
								    cond:{ //条件
								        eq:{ // 多条件对象
					                    }
								    }
							};
							ProgramLibqueryList({},function(data){
							   var tlist=data
								  // alert(JSON.stringify(tlist))
								getProgramExamRecordList(queryData,function(data){
									app.list=data.records;
									  //  alert(JSON.stringify(app.list))
									for(var i=0;i<app.list.length; ++i){
										app.list[i].index = i+1
										app.list[i].matchName=app.getMatchName(app.list[i].matchId)
										app.list[i].zoneName=app.getZoneName(app.list[i].zoneId)
	                  app.list[i].gradeName=app.getGradeName(app.list[i].gradeId)
										app.list[i].scheduleName=app.getsaicheng(app.list[i].sheduleId)
										var yulandizhi=''
										for (j=0;j<tlist.length;j++){
											   if (app.list[i].examId==tlist[j].id){
													 yulandizhi=tlist[j].reviewEditorUrl
													 break
												 }
										}
										app.list[i].yulandizhi=yulandizhi
										// alert(yulandizhi)
									}
									app.total=app.list.length
									app.init()
									setTimeout(function(){
										form.render()
									},1000)

								})
							})


							})
					})
					})
					})

				// this.init()
			},
			init:function() {
				var that = this
				layui.use(['laypage','table'], function () {
					// var laypage = layui.laypage;
					// //执行一个laypage实例
					// laypage.render({
					// 	elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
					// 	,count: 16 //数据总数，从服务端得到
					// });
					var table = layui.table
					//头工具栏事件
					table.render({
						elem: '#test',
						url:'',
						title: '用户数据表',
						cols: [that.cols],
						page: true,
						data: that.list
					})
				})
			}
		}
	})
	window.onload=function(){
		app.getData()
	}
	function search(){
		var saixiang=document.getElementById("saixiang").value
		var saiqu=document.getElementById("saiqu").value
		var zubie=document.getElementById("zubie").value
		var zhanghao=document.getElementById("zhanghao").value
		var list=[]
		for (i=0;i<app.list.length;i++){
				if (app.list[i].matchName.indexOf(saixiang)>-1&&app.list[i].zoneName.indexOf(saiqu)>-1&&app.list[i].gradeName.indexOf(zubie)>-1){
					list.push(app.list[i])
				}
		}
	 //  alert(JSON.stringify(list))
		var table = layui.table
		//头工具栏事件
		table.render({
			elem: '#test',
			url:'',
			title: '用户数据表',
			cols: [app.cols],
			page: true,
			data:list,
			limit:1000
		})

	}
</script>
<script src="./js/jquery.min.js"></script>
<script type="text/html" id="works">
	<a target="_blank" href="javascript:;" class="layui-table-link">下载</a>
</script>
<script type="text/html" id="operating">
<a href="javascript:;" onclick="xadmin.open('裁判','viewReferee1.html?id='+{{d.judgeId}}+'&&name='+{{d.nickName}}+'&&workId='+{{d.id}},600,400)" class="layui-table-link">查看裁判</a>
</script>
<script>
	$(function () {
		layui.use(['form', 'table'], function () {
			var form = layui.form
			// layer.msg('玩命卖萌中', function(){
			//   //关闭后的操作
			//   });
			//监听提交
			form.on('submit(sreach)', function (data) {
				console.log(data)
				// layer.msg(JSON.stringify(data.field), function () {
				// location.href = 'index.html'
				// })
				return false
			})


			var table = layui.table

			table.on('checkbox(test)', function(obj){ //
				console.log(obj.checked); //当前是否选中状态
				console.log(obj.data); //选中行的相关数据
				console.log(obj.type); //如果触发的是全选，则为：all，如果触发的是单选，则为：one
				console.log(table.checkStatus('test').data); // 获取表格中选中行的数据
				if (table.checkStatus('test').data.length === 0) {
					$("#referee").addClass('layui-btn-disabled')
				} else {
					$("#referee").removeClass('layui-btn-disabled')
				}

			});
		})


	})
</script>
<script type="text/html" id="operating2">
<a href="Preview.html?url1={{d.file}}&url2={{d.yulandizhi}}" target="_blank" class="layui-table-link">预览</a>
</script>
</html>
